package com.edu.leetcode.dataStruct;

import java.util.Arrays;

/**
 * 后面自己写一个数组后移的方法！！！
 * @作者 five-five
 * @创建时间 2021/5/13
 */
public class Demo32 {
    public static void main(String[] args) {
        Demo32 demo32 = new Demo32();
        int[] ints = {1, 2, 3, 4};
    }

    public void moveZeroes(int[] nums) {
        int n = nums.length, left = 0, right = 0;
        while (right < n) {
            if (nums[right] != 0) {
                swap(nums, left, right);
                left++;
            }
            right++;
        }
    }

    public void swap(int[] nums, int left, int right) {
        int temp = nums[left];
        nums[left] = nums[right];
        nums[right] = temp;
    }

}
